package com.zprmb.udzt;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
 * 我的QQ
 * @author shenshao
 *
 */
public class MyOicq extends QQActivity implements OnClickListener{
	
	private TextView tv_update,tv_my_qq;
	private ImageView img_back,img_join;
	private RelativeLayout rl_back;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_qq);
		 BbtApplication.getInstance().addActvity(this);
		img_back=(ImageView)findViewById(R.id.img_back);
		tv_update=(TextView)findViewById(R.id.tv_update);
		tv_my_qq=(TextView)findViewById(R.id.tv_my_qq);
		tv_my_qq.setText(getIntent().getStringExtra("qq"));
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		img_join=(ImageView)findViewById(R.id.join_qq_group);
		img_join.setOnClickListener(this);
		rl_back.setOnClickListener(this);
		tv_update.setOnClickListener(this);
		img_back.setOnClickListener(this);
		
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		BbtApplication.getInstance().removeActvity(this);
	}
	
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Log.e("qq", "onresume");
		
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.img_back:
			finish();
			break;
		case R.id.tv_update:
			Intent intent=new Intent(MyOicq.this,Update_My_QQ.class);
			intent.putExtra("where", "1");
			startActivity(intent);
			finish();
			break;
		case R.id.rl_back:
			finish();
			break;
		case R.id.join_qq_group:
			joinQQGroup("dYKhVAU5hwpBBFGWW0PPRgOLDi9-xdcd");
			
			break;
		}
	}
	public boolean joinQQGroup(String key) {  
	    Intent intent = new Intent();  
	    intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
	     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	   // 此Flag可根据具体产品需要自定义，如设置，则在加群界面按返回，返回手Q主界面，不设置，按返回会返回到呼起产品界面    //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)  
	    try {  
	        startActivity(intent);  
	        return true;  
	    } catch (Exception e) {  
	        // 未安装手Q或安装的版本不支持  
	        return false;  
	    }  
	} 

}
